<template>
  <view class="fxyq-wrapper" style="background: url(/static/ymq_canyino2o/fxyq.png);background-size: 100% 100%;">
    <view class="head" style="padding-top: 80%;">
      <!-- <image mode="aspectFill" :src="url + fxset.img"></image> -->
    </view>
    <view class="footer1" style="width: 90%;margin: 0 auto;background: #FEF9F0;border-radius: 20rpx;">
      <view class="t_c pa_0">
				<view class="fon_28 color_6 pa_0">红包在路上</view>
        <view style="color: #D8301D;">
          <text class="fon_50 wei">{{ fxdata.djsyj }}</text>
          <text class="fon_24">元</text>
        </view>
      </view>
			<view class="line">
				
			</view>
      <view class="t_c pa_0">
        <view class="fon_28 color_6 pa_0">累计获得</view>
        <view style="color: #D8301D;">
          <text class="fon_50 wei">{{ fxdata.ljyj }}</text>
          <text class="fon_24">元</text>
        </view>
      </view>
			
			<view class="line">
				
			</view>
      <view class="t_c pa_0">
        <view class="fon_28 color_6 pa_0">成功邀请</view>
        <view style="color: #D8301D;">
          <text class="fon_50 wei">{{ fxdata.rs }}</text>
          <text class="fon_24">人</text>
        </view>
      </view>
    </view>
    <view class="rule mar_t ba_f pa" style="width: 90%;margin: 20rpx auto;background: #FEF9F0;border-radius: 20rpx;">
      <view class="t_c fon_30" style="font-weight: 600;">活动规则</view>
      <view class="fon_28 color_6 pa_0" style="padding: 60rpx 0;">
        <rich-text :nodes="fxset.instructions"></rich-text>
      </view>
			<view class="body-btn">
			  <button :style="'background:' + color" v-if="isfxs == '1'">
			    等待审核
			  </button>
				<button
				  @tap="se_code"
				  class="color_6"
				  :style="'color:#D8301D'+ ';border:2rpx solid #D8301D'"
				  v-if="isfxs == '2'"
				>
				  我的{{ fxset.fx_name }}
				</button>
			  <button
			    openType="share"
			    :style="'background:#D8301D;color: #fff'"
			    v-if="isfxs == '2'"
			  >
			    立即邀请
			  </button>
			  <button @tap="ljsq" :style="'background:' + color" v-if="isfxs == '3'">
			    立即申请
			  </button>
			</view>
    </view>
    <view class="sele_fixed" v-if="!select_code">
      <view @tap="se_code" class="ab"></view>
      <view class="ab udlr"></view>
    </view>
  </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index'
import gettel from '@/ymq_canyino2o/dist/gettel/index'
var app = getApp()
export default {
  components: {
    cardlist,
    gettel
  },
  data() {
    return {
      color: '#459cf9',
      select_code: true,
      userid: '',
      username: '',
      pt_name: '',
      url: '',

      fxset: {
        img: '',
        fx_name: '',
        instructions: ''
      },

      fxdata: {
        djsyj: '',
        ljyj: '',
        rs: ''
      },

      isfxs: 0
    }
  },
  onLoad: function (t) {
    uni.hideShareMenu({})
    app.globalData.setNavigationBarColor(this)
    var that = this
    var a = uni.getStorageSync('users')
    console.log(a)
    this.setData({
      userid: a.id,
      username: a.name,
      pt_name: getApp().globalData.xtxx.url_name
    })
    app.globalData.util.request({
      url: 'entry/wxapp/Url',
      cachetime: '0',
      success: function (t) {
        console.log(t)
        that.setData({
          url: t.data
        })
      }
    })
    app.globalData.util.request({
      url: 'entry/wxapp/CheckRetail',
      cachetime: '0',
      success: function (t) {
        console.log(t)
        that.setData({
          fxset: t.data
        })
      }
    })
    this.reLoad()
  },
  onReady: function () {},
  onShow: function () {
    var that = this
    var t = uni.getStorageSync('users').id
    console.log(t)
    app.globalData.util.request({
      url: 'entry/wxapp/GetFxData',
      cachetime: '0',
      data: {
        user_id: t
      },
      success: function (t) {
        console.log(t.data)
        that.setData({
          fxdata: t.data
        })
      }
    })
  },
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function (t) {
    console.log(this.pt_name, this.userid, this.username)
    console.log(t)
    return (
      'menu' !== t.from && {
        title: this.username + '邀请你来看看' + this.pt_name,
        path: '/ymq_canyino2o/pages/Liar/loginindex?userid=' + this.userid,
        success: function (t) {},
        fail: function (t) {}
      }
    )
  },
  onShareTimeline: function (t) {
    console.log(this.pt_name, this.userid, this.username)
    console.log(t)
    return (
      'menu' !== t.from && {
        title: this.username + '邀请你来看看' + this.pt_name,
        path: '/ymq_canyino2o/pages/Liar/loginindex?userid=' + this.userid,
        success: function (t) {},
        fail: function (t) {}
      }
    )
  },
  methods: {
    ljsq: function () {
      uni.navigateTo({
        url: 'jrhhr'
      })
    },

    reLoad: function () {
      var that = this
      var t = uni.getStorageSync('users').id
      console.log(t)
      app.globalData.util.request({
        url: 'entry/wxapp/MyDistribution',
        cachetime: '0',
        data: {
          user_id: t
        },
        success: function (t) {
          console.log(t.data)
          if ('2' == t.data.state) {
            console.log('是分销商')
            that.setData({
              isfxs: 2
            })
          } else {
            if ('1' == t.data.state) {
              console.log('待审核')
              that.setData({
                isfxs: 1
              })
            } else {
              console.log('未申请过')
              that.setData({
                isfxs: 3
              })
            }
          }
        }
      })
    },

    se_code: function (t) {
      uni.navigateTo({
        url: 'core'
      })
    }
  }
}
</script>
<style>
@import './index.css';
</style>
<style lang="scss" scoped>
	.fxyq-wrapper {
		width: 100vw;
		height: 100vh;
	}
</style>
